/// Qualab - 24/11/2011

#pragma once

#include <wink/types.h>
#include <wink/window.h>

namespace wink
{
    class WindowData
    {
    public:
        WindowData();

        WindowData( PString text, int width = CW_USEDEFAULT, int height = CW_USEDEFAULT,
                    int x = CW_USEDEFAULT, int y = CW_USEDEFAULT, int show_mode = SW_NORMAL );

        WindowData( HWND handle );

        WindowData( const WindowData& source );

        virtual ~WindowData();

        WindowData& operator = ( const WindowData& source );

        void Create( LPCTSTR text, int width = CW_USEDEFAULT, int height = CW_USEDEFAULT,
                     int x = CW_USEDEFAULT, int y = CW_USEDEFAULT, int show_mode = SW_NORMAL );

        HWND Handle() const;

        bool operator == ( const WindowData& other ) const;
        bool operator != ( const WindowData& other ) const;

        const Rect& Shape()  const;
        const Rect& Client() const;

        int Left()   const;
        int Top()    const;
        int Right()  const;
        int Bottom() const;

        int Width()  const;
        int Height() const;

        int ClientWidth()  const;
        int ClientHeight() const;

        void UpdateRect();

        void Close();
        void Reset();

        void       SetOnMove( Window::OnMoveProc       proc );
        void     SetOnResize( Window::OnResizeProc     proc );
        void SetOnMouseLDown( Window::OnMouseLDownProc proc );
        void   SetOnMouseLUp( Window::OnMouseLUpProc   proc );
        void      SetOnClose( Window::OnCloseProc      proc );

        int        OnMove( Window& source );
        int      OnResize( Window& source );
        int  OnMouseLDown( Window& source, int x, int y );
        int    OnMouseLUp( Window& source, int x, int y );
        void      OnClose( Window& source );

    private:
        HWND    mHandle;

        Rect    mShape;
        Rect    mClient;

        struct Events
        {
            Window::OnMoveProc       OnMove;
            Window::OnResizeProc     OnResize;
            Window::OnMouseLDownProc OnMouseLDown;
            Window::OnMouseLUpProc   OnMouseLUp;
            Window::OnCloseProc      OnClose;

            Events()
                : OnMove(),
                  OnResize(),
                  OnMouseLDown(),
                  OnMouseLUp(),
                  OnClose()
            {
            }

        } mEvents;
    };
}
